<template>
  <view>
    <cu-custom :isBack="true" bgColor="bg-white">
      <block slot="backText">返回</block>
      <block slot="content">装备进阶材料</block>
    </cu-custom>
    <scroll-view scroll-x class="bg-white nav">
      <view class="flex text-center">
        <view v-for="(item,index) in tab" :class="index==current?'bg-orange cur':''" class="cu-item flex-sub"
              @click="sectionChange(index)" style="line-height: 70rpx;">
          {{ item }}
        </view>
      </view>
      <view class="flex text-center margin-top-xs">
        <view v-for="(item,index) in list" :class="index==curNow?'text-orange cur':''" class="cu-item flex-sub"
              @click="sectionChildrenChange(index)" style="line-height: 70rpx;">
          {{ item }}
        </view>
      </view>
    </scroll-view>
    <view>
      <ad unit-id="adunit-885d5111d84ebfdb" ad-type="video" ad-theme="white"></ad>
    </view>
    <view class="margin-top-xxl card">
      <view class="cu-form-group">
        <view class="title">目前的等级:</view>
        <input v-model="levelnow" @click="showSheet('now')" placeholder="请选择当前等级"
               :disabled="true"></input>
      </view>
      <view class="cu-form-group margin-top-xxl">
        <view class="title">进阶的等级:</view>
        <input v-model="levelwant" @click="showSheet('want')" placeholder="请选择进阶等级" :disabled="true"></input>
      </view>
      <view class="cu-form-group">
        <view class="title">赤金龙鳞石:</view>
        <input type="number" v-model="cjlls" placeholder="你目前拥有的赤金龙鳞石数量"></input>
      </view>
      <view class="cu-form-group">
        <view class="title">装备进阶石:</view>
        <input type="number" v-model="zbjjs" placeholder="你目前拥有的装备进阶石数量"></input>
      </view>
      <view class="cu-form-group">
        <view class="title">
          <text>{{ curNow == 0 ? "武器" : curNow == 1 ? "衣服" : curNow == 2 ? "头盔" : "项链" }}</text>
          的精华
        </view>
        <input type="number" v-model="jh" placeholder="你目前拥有的武器精华数量"></input>
        <button class="cu-btn bg-green shadow" @click="calc">Go!</button>
      </view>
    </view>

    <u-action-sheet cancelText="取消" @close="closeSheet" :actions="level" :show="show" @select="selectSheet">
    </u-action-sheet>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        tab: ["套 装", "散 装"],
        current: 0,
        list: ['武器', '衣服', '头盔', '项链'],
        curNow: 0,
        show: false,
        level: [{
          name: '红0',
          wqcjlls: 0,
          wqzbjjs: 50,
          wqjh: 10,
          yfcjlls: 0,
          yfzbjjs: 25,
          yfjh: 5,
          tkcjlls: 0,
          tkzbjjs: 25,
          tkjh: 5,
          xlcjlls: 0,
          xlzbjjs: 45,
          xljh: 9,
          level: 0
        },
          {
            name: '红1',
            wqcjlls: 0,
            wqzbjjs: 150,
            wqjh: 30,
            yfcjlls: 0,
            yfzbjjs: 75,
            yfjh: 15,
            tkcjlls: 0,
            tkzbjjs: 75,
            tkjh: 15,
            xlcjlls: 0,
            xlzbjjs: 135,
            xljh: 27,
            level: 1
          },
          {
            name: '红2',
            wqcjlls: 0,
            wqzbjjs: 300,
            wqjh: 60,
            yfcjlls: 0,
            yfzbjjs: 150,
            yfjh: 30,
            tkcjlls: 0,
            tkzbjjs: 150,
            tkjh: 30,
            xlcjlls: 0,
            xlzbjjs: 270,
            xljh: 54,
            level: 2
          },
          {
            name: '红3',
            wqcjlls: 0,
            wqzbjjs: 500,
            wqjh: 100,
            yfcjlls: 0,
            yfzbjjs: 250,
            yfjh: 50,
            tkcjlls: 0,
            tkzbjjs: 250,
            tkjh: 50,
            xlcjlls: 0,
            xlzbjjs: 450,
            xljh: 90,
            level: 3
          },
          {
            name: '红4',
            wqcjlls: 0,
            wqzbjjs: 750,
            wqjh: 150,
            yfcjlls: 0,
            yfzbjjs: 375,
            yfjh: 75,
            tkcjlls: 0,
            tkzbjjs: 375,
            tkjh: 75,
            xlcjlls: 0,
            xlzbjjs: 675,
            xljh: 135,
            level: 4
          },
          {
            name: '红5',
            wqcjlls: 0,
            wqzbjjs: 1050,
            wqjh: 210,
            yfcjlls: 0,
            yfzbjjs: 525,
            yfjh: 105,
            tkcjlls: 0,
            tkzbjjs: 525,
            tkjh: 105,
            xlcjlls: 0,
            xlzbjjs: 945,
            xljh: 189,
            level: 5
          },
          {
            name: '金0',
            wqcjlls: 50,
            wqzbjjs: 1070,
            wqjh: 220,
            yfcjlls: 25,
            yfzbjjs: 535,
            yfjh: 110,
            tkcjlls: 25,
            tkzbjjs: 535,
            tkjh: 110,
            xlcjlls: 45,
            xlzbjjs: 963,
            xljh: 198,
            level: 6
          },
          {
            name: '金1',
            wqcjlls: 150,
            wqzbjjs: 1110,
            wqjh: 240,
            yfcjlls: 75,
            yfzbjjs: 555,
            yfjh: 120,
            tkcjlls: 75,
            tkzbjjs: 555,
            tkjh: 120,
            xlcjlls: 135,
            xlzbjjs: 999,
            xljh: 216,
            level: 7
          },
          {
            name: '金2',
            wqcjlls: 300,
            wqzbjjs: 1170,
            wqjh: 270,
            yfcjlls: 150,
            yfzbjjs: 585,
            yfjh: 135,
            tkcjlls: 150,
            tkzbjjs: 585,
            tkjh: 135,
            xlcjlls: 270,
            xlzbjjs: 1053,
            xljh: 243,
            level: 8
          },
          {
            name: '金3',
            wqcjlls: 500,
            wqzbjjs: 1250,
            wqjh: 310,
            yfcjlls: 250,
            yfzbjjs: 625,
            yfjh: 155,
            tkcjlls: 250,
            tkzbjjs: 625,
            tkjh: 155,
            xlcjlls: 450,
            xlzbjjs: 1125,
            xljh: 279,
            level: 9
          },
          {
            name: '金4',
            wqcjlls: 750,
            wqzbjjs: 1350,
            wqjh: 360,
            yfcjlls: 375,
            yfzbjjs: 675,
            yfjh: 180,
            tkcjlls: 375,
            tkzbjjs: 675,
            tkjh: 180,
            xlcjlls: 675,
            xlzbjjs: 1215,
            xljh: 324,
            level: 10
          },
          {
            name: '金5',
            wqcjlls: 1050,
            wqzbjjs: 1470,
            wqjh: 420,
            yfcjlls: 525,
            yfzbjjs: 735,
            yfjh: 210,
            tkcjlls: 525,
            tkzbjjs: 735,
            tkjh: 210,
            xlcjlls: 945,
            xlzbjjs: 1323,
            xljh: 378,
            level: 11
          }
        ],
        levelnow: "",
        levelwant: "",
        cjlls: "",
        zbjjs: "",
        jh: "",
        type: ""
      }
    },
    methods: {
      sectionChange(index) {
        this.current = index;
        this.levelnow = ""
        this.levelwant = ""
        this.cjlls = ""
        this.zbjjs = ""
        this.jh = ""
        if (this.current == 1) {
          this.level = [{
            name: '红0',
            wqcjlls: 0,
            wqzbjjs: 25,
            wqjh: 5,
            yfcjlls: 0,
            yfzbjjs: 13,
            yfjh: 3,
            tkcjlls: 0,
            tkzbjjs: 13,
            tkjh: 3,
            xlcjlls: 0,
            xlzbjjs: 23,
            xljh: 5,
            level: 0
          },
            {
              name: '红1',
              wqcjlls: 0,
              wqzbjjs: 75,
              wqjh: 15,
              yfcjlls: 0,
              yfzbjjs: 38,
              yfjh: 8,
              tkcjlls: 0,
              tkzbjjs: 38,
              tkjh: 8,
              xlcjlls: 0,
              xlzbjjs: 68,
              xljh: 14,
              level: 1
            },
            {
              name: '红2',
              wqcjlls: 0,
              wqzbjjs: 150,
              wqjh: 30,
              yfcjlls: 0,
              yfzbjjs: 76,
              yfjh: 16,
              tkcjlls: 0,
              tkzbjjs: 76,
              tkjh: 16,
              xlcjlls: 0,
              xlzbjjs: 136,
              xljh: 28,
              level: 2
            },
            {
              name: '红3',
              wqcjlls: 0,
              wqzbjjs: 250,
              wqjh: 50,
              yfcjlls: 0,
              yfzbjjs: 126,
              yfjh: 26,
              tkcjlls: 0,
              tkzbjjs: 126,
              tkjh: 26,
              xlcjlls: 0,
              xlzbjjs: 226,
              xljh: 46,
              level: 3
            },
            {
              name: '红4',
              wqcjlls: 0,
              wqzbjjs: 375,
              wqjh: 75,
              yfcjlls: 0,
              yfzbjjs: 189,
              yfjh: 39,
              tkcjlls: 0,
              tkzbjjs: 189,
              tkjh: 39,
              xlcjlls: 0,
              xlzbjjs: 339,
              xljh: 69,
              level: 4
            },
            {
              name: '红5',
              wqcjlls: 0,
              wqzbjjs: 525,
              wqjh: 105,
              yfcjlls: 0,
              yfzbjjs: 264,
              yfjh: 54,
              tkcjlls: 0,
              tkzbjjs: 264,
              tkjh: 54,
              xlcjlls: 0,
              xlzbjjs: 474,
              xljh: 96,
              level: 5
            },
            {
              name: '金0',
              wqcjlls: 25,
              wqzbjjs: 535,
              wqjh: 110,
              yfcjlls: 13,
              yfzbjjs: 269,
              yfjh: 57,
              tkcjlls: 13,
              tkzbjjs: 269,
              tkjh: 57,
              xlcjlls: 23,
              xlzbjjs: 483,
              xljh: 101,
              level: 6
            },
            {
              name: '金1',
              wqcjlls: 75,
              wqzbjjs: 555,
              wqjh: 120,
              yfcjlls: 38,
              yfzbjjs: 279,
              yfjh: 62,
              tkcjlls: 38,
              tkzbjjs: 279,
              tkjh: 62,
              xlcjlls: 68,
              xlzbjjs: 501,
              xljh: 110,
              level: 7
            },
            {
              name: '金2',
              wqcjlls: 150,
              wqzbjjs: 585,
              wqjh: 135,
              yfcjlls: 76,
              yfzbjjs: 294,
              yfjh: 70,
              tkcjlls: 76,
              tkzbjjs: 294,
              tkjh: 70,
              xlcjlls: 136,
              xlzbjjs: 528,
              xljh: 124,
              level: 8
            },
            {
              name: '金3',
              wqcjlls: 250,
              wqzbjjs: 625,
              wqjh: 155,
              yfcjlls: 126,
              yfzbjjs: 314,
              yfjh: 80,
              tkcjlls: 126,
              tkzbjjs: 314,
              tkjh: 80,
              xlcjlls: 226,
              xlzbjjs: 564,
              xljh: 142,
              level: 9
            },
            {
              name: '金4',
              wqcjlls: 375,
              wqzbjjs: 675,
              wqjh: 180,
              yfcjlls: 189,
              yfzbjjs: 339,
              yfjh: 93,
              tkcjlls: 189,
              tkzbjjs: 339,
              tkjh: 93,
              xlcjlls: 339,
              xlzbjjs: 609,
              xljh: 165,
              level: 10
            },
            {
              name: '金5',
              wqcjlls: 525,
              wqzbjjs: 735,
              wqjh: 210,
              yfcjlls: 264,
              yfzbjjs: 369,
              yfjh: 108,
              tkcjlls: 264,
              tkzbjjs: 369,
              tkjh: 108,
              xlcjlls: 474,
              xlzbjjs: 663,
              xljh: 192,
              level: 11
            }
          ]
        } else {
          this.level = [{
            name: '红0',
            wqcjlls: 0,
            wqzbjjs: 50,
            wqjh: 10,
            yfcjlls: 0,
            yfzbjjs: 25,
            yfjh: 5,
            tkcjlls: 0,
            tkzbjjs: 25,
            tkjh: 5,
            xlcjlls: 0,
            xlzbjjs: 45,
            xljh: 9,
            level: 0
          },
            {
              name: '红1',
              wqcjlls: 0,
              wqzbjjs: 150,
              wqjh: 30,
              yfcjlls: 0,
              yfzbjjs: 75,
              yfjh: 15,
              tkcjlls: 0,
              tkzbjjs: 75,
              tkjh: 15,
              xlcjlls: 0,
              xlzbjjs: 135,
              xljh: 27,
              level: 1
            },
            {
              name: '红2',
              wqcjlls: 0,
              wqzbjjs: 300,
              wqjh: 60,
              yfcjlls: 0,
              yfzbjjs: 150,
              yfjh: 30,
              tkcjlls: 0,
              tkzbjjs: 150,
              tkjh: 30,
              xlcjlls: 0,
              xlzbjjs: 270,
              xljh: 54,
              level: 2
            },
            {
              name: '红3',
              wqcjlls: 0,
              wqzbjjs: 500,
              wqjh: 100,
              yfcjlls: 0,
              yfzbjjs: 250,
              yfjh: 50,
              tkcjlls: 0,
              tkzbjjs: 250,
              tkjh: 50,
              xlcjlls: 0,
              xlzbjjs: 450,
              xljh: 90,
              level: 3
            },
            {
              name: '红4',
              wqcjlls: 0,
              wqzbjjs: 750,
              wqjh: 150,
              yfcjlls: 0,
              yfzbjjs: 375,
              yfjh: 75,
              tkcjlls: 0,
              tkzbjjs: 375,
              tkjh: 75,
              xlcjlls: 0,
              xlzbjjs: 675,
              xljh: 135,
              level: 4
            },
            {
              name: '红5',
              wqcjlls: 0,
              wqzbjjs: 1050,
              wqjh: 210,
              yfcjlls: 0,
              yfzbjjs: 525,
              yfjh: 105,
              tkcjlls: 0,
              tkzbjjs: 525,
              tkjh: 105,
              xlcjlls: 0,
              xlzbjjs: 945,
              xljh: 189,
              level: 5
            },
            {
              name: '金0',
              wqcjlls: 50,
              wqzbjjs: 1070,
              wqjh: 220,
              yfcjlls: 25,
              yfzbjjs: 535,
              yfjh: 110,
              tkcjlls: 25,
              tkzbjjs: 535,
              tkjh: 110,
              xlcjlls: 45,
              xlzbjjs: 963,
              xljh: 198,
              level: 6
            },
            {
              name: '金1',
              wqcjlls: 150,
              wqzbjjs: 1110,
              wqjh: 240,
              yfcjlls: 75,
              yfzbjjs: 555,
              yfjh: 120,
              tkcjlls: 75,
              tkzbjjs: 555,
              tkjh: 120,
              xlcjlls: 135,
              xlzbjjs: 999,
              xljh: 216,
              level: 7
            },
            {
              name: '金2',
              wqcjlls: 300,
              wqzbjjs: 1170,
              wqjh: 270,
              yfcjlls: 150,
              yfzbjjs: 585,
              yfjh: 135,
              tkcjlls: 150,
              tkzbjjs: 585,
              tkjh: 135,
              xlcjlls: 270,
              xlzbjjs: 1053,
              xljh: 243,
              level: 8
            },
            {
              name: '金3',
              wqcjlls: 500,
              wqzbjjs: 1250,
              wqjh: 310,
              yfcjlls: 250,
              yfzbjjs: 625,
              yfjh: 155,
              tkcjlls: 250,
              tkzbjjs: 625,
              tkjh: 155,
              xlcjlls: 450,
              xlzbjjs: 1125,
              xljh: 279,
              level: 9
            },
            {
              name: '金4',
              wqcjlls: 750,
              wqzbjjs: 1350,
              wqjh: 360,
              yfcjlls: 375,
              yfzbjjs: 675,
              yfjh: 180,
              tkcjlls: 375,
              tkzbjjs: 675,
              tkjh: 180,
              xlcjlls: 675,
              xlzbjjs: 1215,
              xljh: 324,
              level: 10
            },
            {
              name: '金5',
              wqcjlls: 1050,
              wqzbjjs: 1470,
              wqjh: 420,
              yfcjlls: 525,
              yfzbjjs: 735,
              yfjh: 210,
              tkcjlls: 525,
              tkzbjjs: 735,
              tkjh: 210,
              xlcjlls: 945,
              xlzbjjs: 1323,
              xljh: 378,
              level: 11
            }
          ]
        }
      },

      sectionChildrenChange(index) {
        this.curNow = index
        this.levelnow = ""
        this.levelwant = ""
        this.cjlls = ""
        this.zbjjs = ""
        this.jh = ""
      },
      showSheet(type) {
        this.show = true
        this.type = type
      },
      selectSheet(e) {
        this.show = false
        if (this.type == "now") {
          this.levelnow = e.name
        } else {
          this.levelwant = e.name
        }
      },
      closeSheet() {
        this.show = false
      },
      calc() {
        if (!this.levelnow || !this.levelwant) {
          uni.showToast({
            title: "兄得~别搞事情",
            icon: "none"
          })
          return
        }
        const arrNow = this.level.filter(item => {
          return item.name == this.levelnow
        })
        const arrWant = this.level.filter(item => {
          return item.name == this.levelwant
        })
        if (arrNow[0].level > arrWant[0].level) {
          uni.showModal({
            title: "生气!!!",
            content: "小伙子别搞事情啊~~"
          })
          return
        }
        uni.showModal({
          title: "小伙子~",
          content: `${this.curNow == 0 ? "武器" : this.curNow == 1 ? "衣服" : this.curNow == 2 ? "头盔" : "项链"}从${this.levelnow}进阶到${this.levelwant}需要${this.curNow == 0 ? arrWant[0].wqcjlls - arrNow[0].wqcjlls - this.cjlls : this.curNow == 1 ? arrWant[0].yfcjlls - arrNow[0].yfcjlls - this.cjlls : this.curNow == 2 ? arrWant[0].tkcjlls - arrNow[0].tkcjlls - this.cjlls : arrWant[0].xlcjlls - arrNow[0].xlcjlls - this.cjlls}个赤金龙鳞石, ${this.curNow == 0 ? arrWant[0].wqzbjjs - arrNow[0].wqzbjjs - this.zbjjs : this.curNow == 1 ? arrWant[0].yfzbjjs - arrNow[0].yfzbjjs - this.zbjjs : this.curNow == 2 ? arrWant[0].tkzbjjs - arrNow[0].tkzbjjs - this.zbjjs : arrWant[0].xlzbjjs - arrNow[0].xlzbjjs - this.zbjjs}个装备进阶石, ${this.curNow == 0 ? arrWant[0].wqjh - arrNow[0].wqjh - this.jh : this.curNow == 1 ? arrWant[0].yfjh - arrNow[0].yfjh - this.jh : this.curNow == 2 ? arrWant[0].tkjh - arrNow[0].tkjh - this.jh : arrWant[0].xljh - arrNow[0].xljh - this.jh}个${this.curNow == 0 ? "武器" : this.curNow == 1 ? "衣服" : this.curNow == 2 ? "头盔" : "项链"}精华`,
          showCancel: false
        })
      }
    }
  }
</script>

<style scoped lang="less">
  .card {
    background-image: url('https://mmbiz.qpic.cn/mmbiz_jpg/8iaIEbCVSqJZfILHPjJVoekw9ic8GfibSCibtjU4yWuOSXTOw2j4BrEkfz5iauKyPtIH2y9qPdbiaxYc4F8CR1mzwJHg/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1');
    background-size: cover;
    background-position: center center;
  }

  .cu-form-group {
    background-color: rgba(255, 255, 255, 0.8);
  }
</style>
